package mspbots.data.sync.script;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import mspbots.data.sync.BaseReceiver;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

import java.util.Map;

/**
 * @author Jay.Yang
 */

@Service
@Log4j2
@RequiredArgsConstructor
public class DataSourceServiceImpl extends BaseReceiver implements DataSourceService {

    @Override
    public Flux<DataSourceResult> getSourceData(Map<String, Object> map) {
        String sql = map.get("sql").toString();
        return super.databaseClient.execute(sql)
                .as(DataSourceResult.class)
                .fetch().all();
    }
}
